package com.baolelei.Threelogin;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.view.Gravity;

import com.external.androidquery.callback.AjaxStatus;
import com.insthub.BeeFramework.model.BaseModel;
import com.insthub.BeeFramework.model.BeeCallback;
import com.insthub.BeeFramework.view.ToastView;
import com.xingongchang.baolebei.model.ProtocolConst;
import com.xingongchang.baolebei.protocol.STATUS;

public class ThreeLoginModel extends BaseModel{
	public void loginTwo(){
		String url = ProtocolConst.DISANFANG;
	    BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>(){
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				STATUS responseStatus;
				try {
					responseStatus = STATUS.fromJson(jo.optJSONObject("status"));
					if(responseStatus.succeed==1){
						JSONObject object=jo.optJSONObject("data");
						int status2=object.optInt("status");
						if(status2==2){
							ToastView toast = new ToastView(mContext,"请添加信息");
	                        toast.setGravity(Gravity.CENTER, 0, 0);
	                        toast.show();
	                        return;
						}
						 
					}else if(responseStatus.succeed==0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
                        toast.setGravity(Gravity.CENTER, 0, 0);
                        toast.show();
                        return;
					}
					} catch (JSONException e) {
						e.printStackTrace();
					}
			  } 
			};
			cb.url(url).type(JSONObject.class);
	        aq.ajax(cb);
    }
}
